const cloud = require('@alipay/faas-server-sdk');


exports.main = async (event, context) => {
  // 初始化
  cloud.init();
  const db = cloud.database();
  const { OPENID } = cloud.getAlipayContext();
  // 生成 collection 名称
  return await db.collection('garbageSearchHistory').where({ _openid: OPENID })
    .limit(10) // 最多返回 10 个
    .orderBy('searchTime', cloud.Sort.DESC)
    .get();
};